package com.fantabest.frontend.client.widget;

import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.IconAlign;
import com.extjs.gxt.ui.client.util.IconHelper;
import com.extjs.gxt.ui.client.util.Padding;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout.VBoxLayoutAlign;

public class TopMenu extends ContentPanel {

	private HorizontalPanel menu;
	private ToggleButton manageButton;
	private ToggleButton rostersButton;
	private ToggleButton squadsButton;
	private ToggleButton calendarButton;
	private ToggleButton resultsButton;
	
	
	public TopMenu() {
		super();
		this.setStyleName("topMenu");
		this.setHeaderVisible(false);
		this.setBodyBorder(false);
		
		VBoxLayout layout = new VBoxLayout();  
        layout.setPadding(new Padding(10,5,5,5));  
        layout.setVBoxLayoutAlign(VBoxLayoutAlign.RIGHT);  
        this.setLayout(layout);
        
        menu = new HorizontalPanel();  
        menu.setSpacing(5);
        
        manageButton = new ToggleButton();
        configureButton(manageButton, "management32");
    	
        rostersButton = new ToggleButton();
        configureButton(rostersButton, "rosters32");
        
    	squadsButton = new ToggleButton();
    	configureButton(squadsButton, "squads32");
    	
    	calendarButton = new ToggleButton();
    	configureButton(calendarButton, "calendar32");
    	
    	resultsButton = new ToggleButton();    
    	configureButton(resultsButton, "results32");
    	

    	menu.add(manageButton);
        menu.add(rostersButton);
        menu.add(squadsButton);
        menu.add(calendarButton);
        menu.add(resultsButton);

        this.add(menu);
	}
	
	private void configureButton(ToggleButton button, String iconStyle)	{
        button.setIcon(IconHelper.createStyle(iconStyle,32,32));
        button.setScale(ButtonScale.LARGE);
        button.setIconAlign(IconAlign.TOP);
	}
	
	public void setEnabledButtons(boolean enabled)	{
		manageButton.setEnabled(enabled);
		rostersButton.setEnabled(enabled);
		squadsButton.setEnabled(enabled);
		calendarButton.setEnabled(enabled);
		resultsButton.setEnabled(enabled);
	}

}
